<?php 
	/**
	 * 不好意思服务器到期了我挂的本地的mysql
	 * db_pdo()自己项目抽出来的方法
	 */
	include_once('Base.class.php');
	class pdoQuestion extends Base{
		public function __construct($dbname){
			$pdo = $this->db_pdo($dbname);

			$sql = 'show tables';
			$stmt = $pdo->prepare($sql);
			$stmt->execute();  
			$rows = $stmt->fetchAll();
			$this->pri($rows);
		}

		public function db_pdo($dbname){
			$db = array(
			    'dsn' => 'mysql:host=localhost;dbname='.$dbname.';port=3306;charset=utf8',
			    'host' => 'localhost',
			    'port' => '3306',
			    'dbname' => $dbname,
			    'username' => 'root',
			    'password' => 'root',
			    'charset' => 'utf8',
			);

			//连接
			$options = array(
			    PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, 
			    PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, 
			);				

			try{
			    $pdo = new PDO($db['dsn'], $db['username'], $db['password'], $options);
			}catch(PDOException $e){
			   	return 0;
			    // die('数据库连接失败:' . $e->getMessage());
			}	
			return $pdo;
		}
	}

	$pdo = new pdoQuestion('internship_tp');
 ?>